package com.starview.star.compiler.format.rules;

import com.starview.platform.data.type.Location;
import com.starview.star.compiler.ast.IAbstract;
import com.starview.star.compiler.standard.StandardNames;
import com.starview.star.compiler.util.PrettyPrintDisplay;

@SuppressWarnings("serial")
public class FmtApplyFormat implements FmtFormatOp
{
  private final FmtBuildOp term;
  private final FmtFormatOp op;

  public FmtApplyFormat(Location loc, FmtBuildOp term, FmtFormatOp op)
  {
    this.term = term;
    this.op = op;
  }

  @Override
  public void format(IAbstract term, Location loc, IAbstract[] env)
  {
    IAbstract t = this.term.build(env, loc);
    op.format(t, loc, env);
  }

  @Override
  public void prettyPrint(PrettyPrintDisplay disp)
  {
    this.term.prettyPrint(disp);
    disp.append(StandardNames.WFF_DEFINES);
    op.prettyPrint(disp);
  }
}
